/**
 * ****************************************************************************
 * Project: RoboBridge
 * ----------------------------------------------------------------------------
 * -------------------------- [c]2012 - KrawallMann ---------------------------
 * ---------------------- http://www.krawallmann.de.tc/ -----------------------
 * ****************************************************************************
 * File: WLANCommunicationInterface.java Package:
 * tc.de.krawallmann.robobridge.communication.lan Version: 1.0 Author(s):
 * KrawallMann
 * ****************************************************************************
 * Description:
 * ****************************************************************************
 */
package tc.de.krawallmann.robobridge.communication.lan.wlan;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.logging.Level;

import tc.de.krawallmann.robobridge.communication.lan.AbstractLANCommunicationInterface;
import tc.de.krawallmann.robobridge.util.Log;

/**
 * The Class WLANCommunicationInterface represents a LAN communication
 * interface.
 * 
 * @author KrawallMann
 * @version 1.0
 */
public class WLANCommunicationInterface extends AbstractLANCommunicationInterface<WLANRemoteDevice> {

	/** The scanner. */
	private transient final WLANDeviceScanner scanner;

	/**
	 * Instantiates a new wLAN communication interface.
	 * 
	 * @throws UnknownHostException
	 *             the unknown host exception
	 */
	public WLANCommunicationInterface() throws UnknownHostException {
		super();
		scanner = new WLANDeviceScanner();
	}

	/*
	 * (non-Javadoc)
	 * @see
	 * tc.de.krawallmann.robobridge.communication.AbstractCommunicationInterface
	 * #getDeviceScanner()
	 */
	@Override
	public WLANDeviceScanner getDeviceScanner() {
		return scanner;
	}

	/*
	 * (non-Javadoc)
	 * @see
	 * tc.de.krawallmann.robobridge.communication.AbstractCommunicationInterface
	 * #startScan()
	 */
	@Override
	public void startScan() throws IOException {
		if (!scanner.isScanning()) {
			Log.log(Level.INFO, getClass(), "startScan", "Device scan started");
			scanner.open();
		}
	}

	/*
	 * (non-Javadoc)
	 * @see
	 * tc.de.krawallmann.robobridge.communication.AbstractCommunicationInterface
	 * #stopScan()
	 */
	@Override
	public void stopScan() {
		Log.log(Level.INFO, getClass(), "startScan", "Device scan stopped");
		scanner.close();
	}

}
